<?php

/**
 * Class base
 */
class base {
	var $seq;
	var $begin;

	/**
	 * 构造函数
	 * @return void
	 */
	public function __construct() {
		$this->begin = strtotime('2015-12-12 00:00:00');
		$this->seq = 1;
	}

	public function bigid($vsId = 1) {
		$seq = ++$this->seq;
		$timestamp = time() - $this->begin;
		$bigId = 1 << 4; // version + reserved
		$bigId = $bigId << 40 | ($timestamp & 0xFFFFFFFFFF); // timestamp
		$bigId = $bigId << 8 | ($vsId & 0xFF); // vsId
		$bigId = $bigId << 10 | ($seq & 0x3FF);// auto increase seq
		return $bigId;
	}
}